<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目状态：</label>
                        <div class="layui-input-block">
                            <select id="state" name="state" lay-filter="state">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>

    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('项目成本汇总');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_cheng_cheng_tong),where: {}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {

                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                var state_str = '<option value="">请选择</option>';
                var state = res.data.state;
                for (var key in state){
                    if(res.data.is_state == key){
                        state_str += '<option value="'+key+'" selected>'+state[key]+'</option>';
                    }else {
                        state_str += '<option value="'+key+'">'+state[key]+'</option>';
                    }

                }
                $("#state").html(state_str);

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field:'name',title:'项目名称',templet: function(d){
                        return '<span class="colorlan" onclick="openPage(\'../engin/show.php?id='+d.id+'\')">'+d.name+'</span>';
                    }}
                ,{field: 'business_name', title: '项目属性'}
                ,{field: 'state_name', title: '项目状态'}
                ,{field:'shimoney',title:'施工合同(含变更)',totalRow: true,align:'right',event: 'contract_shi',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.shimoney)+'</span>';
                    }}
                ,{field: 'lei_chan', title: '累计审定产值',totalRow: true,align:'right',event: 'engin_chan',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_chan)+'</span>';
                    }}
                ,{field: 'lei_huikuan', title: '累计回款',totalRow: true,align:'right',event: 'income_engin',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_huikuan)+'</span>';
                    }}
                ,{field: 'cai_fuku', title: '材料费',totalRow: true,align:'right',event: 'payment_engin1',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.cai_fuku)+'</span>';
                    }}
                ,{field: 'cai_fuku_shi', title: '材料费实付',totalRow: true,align:'right',event: 'payment_engin1',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.cai_fuku_shi)+'</span>';
                    }}
                ,{field: 'ren_fuku', title: '人工费',totalRow: true,align:'right',event: 'payment_engin2',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.ren_fuku)+'</span>';
                    }}
                ,{field: 'ren_fuku_shi', title: '人工费实付',totalRow: true,align:'right',event: 'payment_engin2',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.ren_fuku_shi)+'</span>';
                    }}
                ,{field: 'zu_fuku', title: '机械费',totalRow: true,align:'right',event: 'payment_engin3',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.zu_fuku)+'</span>';
                    }}
                ,{field: 'zu_fuku_shi', title: '机械费实付',totalRow: true,align:'right',event: 'payment_engin3',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.zu_fuku_shi)+'</span>';
                    }}
                ,{field: 'fen_fuku', title: '分包费',totalRow: true,align:'right',event: 'payment_engin4',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.fen_fuku)+'</span>';
                    }}
                ,{field: 'fen_fuku_shi', title: '分包费实付',totalRow: true,align:'right',event: 'payment_engin4',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.fen_fuku_shi)+'</span>';
                    }}
                ,{field: 'cuo_fuku', title: '措施费',totalRow: true,align:'right',event: 'payment_engin5',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.cuo_fuku)+'</span>';
                    }}
                ,{field: 'cuo_fuku_shi', title: '措施费实付',totalRow: true,align:'right',event: 'payment_engin5',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.cuo_fuku_shi)+'</span>';
                    }}
                ,{field: 'lei_payment_bao', title: '项目费用',totalRow: true,align:'right',event: 'payment_bao',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_payment_bao)+'</span>';
                    }}
                ,{field: 'lei_payment_bao_shi', title: '项目费用实付',totalRow: true,align:'right',event: 'payment_bao',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_payment_bao_shi)+'</span>';
                    }}
                ,{field: 'lei_cheng_he', title: '成本合计',totalRow: true,align:'right',templet: function(d){
                        return parseFormatNum(d.lei_cheng_he);
                    }}
                ,{field: 'lei_shi_he', title: '实付合计',totalRow: true,align:'right',templet: function(d){
                        return parseFormatNum(d.lei_shi_he);
                    }}
            ]]
            , done: function (res) {
                soulTable.render(this);
            }
        });

        table.on('tool(datalist)',function (obj) {
            var data = obj.data;
            if(obj.event === 'contract_shi'){
                openPage('../contract_shi/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'engin_chan'){
                openPage('../engin_chan/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'income_engin'){
                openPage('../income_engin/tong.php?enginname='+encodeURI(data.name)+'&status=1&budname='+encodeURI('工程款'), '80%', '80%');
            }
            if(obj.event === 'payment_engin1'){
                openPage('../payment_engin/tong.php?enginname='+encodeURI(data.name)+'&status=1&budid=1', '80%', '80%');
            }
            if(obj.event === 'payment_engin2'){
                openPage('../payment_engin/tong.php?enginname='+encodeURI(data.name)+'&status=1&budid=2', '80%', '80%');
            }
            if(obj.event === 'payment_engin3'){
                openPage('../payment_engin/tong.php?enginname='+encodeURI(data.name)+'&status=1&budid=3', '80%', '80%');
            }
            if(obj.event === 'payment_engin4'){
                openPage('../payment_engin/tong.php?enginname='+encodeURI(data.name)+'&status=1&budid=4', '80%', '80%');
            }
            if(obj.event === 'payment_engin5'){
                openPage('../payment_engin/tong.php?enginname='+encodeURI(data.name)+'&status=1&budid=5', '80%', '80%');
            }
            if(obj.event === 'payment_bao'){
                openPage('../payment_bao/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
        });

        listTableSearch(form, table);
    });




</script>
</body>
</html>
